/**
 * 新弹出框关闭按钮
 * @returns 
 */
function closstan(){
	var clo = document.getElementById("newstan");
	$("#thestart").css('display','block');
	$("#theend").css('display','none');
	$("#thesmile").css('display','none');
	clo.style.display="none";
	
}

/**
 * 申请第一步
 * @returns 
 */
function nextapply()
{
	var name = $("#name").val();
	var mobile = $("#mobilet").val();
	var sex = $('#sexs').val();
	var city = $('#profile_sublocation option:selected').text();
	
	var han = /^[\u4e00-\u9fa5]+$/gi;
	var reg2 = /^(1[0-9]{10})$/;
	var num = /^[1-9]\d*$/;
	
	if(name == '请输入真实姓名' || name == ''){
		alert('姓名不能为空');
		return;
	}
	if(!han.test(name)){
		alert("请输入中文姓名！");
		return;
	}
	
	if(mobile == '请输入手机号码' || mobile == ''){
		alert('手机号码不能为空！');
		return;
	}
	if(!reg2.test(mobile)){
		alert("手机号码格式不正确");
	    return;
	}
	
	if(sex == 0){
		alert('请选择性别！');
		return;
	}
	if(city == '请选择城市'){
		alert('请选择您所在的城市');
		return;
	}
	/*************用户协议**********/
	var agereement = $("#agereement2").val();
	if(agereement == 0){
		alert('请勾选，《助贷网平台服务协议》');
		return false;
	}
	/*************用户协议**********/
	var applystep = document.getElementById('applystep');
	var thestart = document.getElementById('thestart');
	var theend = document.getElementById('theend');
	applystep.src = "https://staticcdn.zhudai.com/default/images/theend.gif";
	thestart.style.display="none";
	theend.style.display="block";
}

/**
 * 申请第二步
 * @returns
 */
function endapply() {
	/*第一步数据*/
	var name = $("#name").val();
	var mobile = $("#mobilet").val();
	var sex = $('#sexs').val();
	var city = $('#profile_sublocation option:selected').text();
	/*第二步数据*/
	var loanmoney = $("#loanmoneys").val();
	var age = $("#age").val();
	var house = $("#house").val();
	var car = $("#car").val();
	var jobid = $("#jobidt").val();
	var pid = $("#pid").val();
	var newsloan = $("#newsloan").val();
	var source = $("#t").val();
	var ismove = 0;
	if(pid=='' || pid==undefined){
		source = newsloan;//资讯过来的贷款申请
	}
	var num = /^[1-9]\d*$/;
	
	if(!num.test(loanmoney)){
		alert('借款金额请输入开头不为0的数字');
		return;
	}
	if(age == '' || age == '请输入年龄'){
		alert('年龄不能为空！');
		return;
	}
	if(!num.test(age)){
		alert('年龄请输入开头不为0的数字');
		return;
	}
	if(house == '未知'){
		alert('请选择有无房产');
		return;
	}
	if(car == '未知'){
		alert('请选择是否有车');
		return;
	}
	if(jobid == 0){
		alert('请选择职业状况');
		return;
	}

	var json_data = {
		'name':name,'mobile':mobile,'sex':sex,
		'city':city,'money':loanmoney,'age':age,
		'house':house,'car':car,'job':jobid,
		'pid':pid,'source':source,'ismove':ismove
	};
	$.ajax({
	    type: 'GET',  //这里用GET
	    url: jiekou_site_url+'/sem/loan_do_baidu.html',
	    dataType: 'jsonp',  //类型
	    data: json_data,
	    jsonp: 'jcallback', //jsonp回调参数，必需
	    async: false,
	    success: function(d) { //返回的json数据
			if(d == '2') {
				alert('验证码错误');
				return;
			}else if(d == '3'){
				alert('亲，24小时内只允许申请一次');
				return;
			}else if(d == '5'){
				alert('系统繁忙');
				return;
			}else{
				var clo = document.getElementById("thesmile");
				var theend = document.getElementById('theend');
				theend.style.display="none";
				clo.style.display="block";
				return;
			}
	    },
	    timeout: 3000
	});	
}